package top.zhaojx.rpc.enumration;

import lombok.AllArgsConstructor;
import lombok.Getter;

/**
 * 字节流中标识序列化和反序列化器
 */
@AllArgsConstructor
@Getter
public enum SerializerCode {

    KYRO((byte) 0x01, "kyro"),
    HESSIAN((byte) 0x02, "hessian"),
    PROTOSTUFF((byte) 0x03, "protostuff");

    private final byte code;
    private final String name;

    public static String getName(byte code) {
        for (SerializerCode c : SerializerCode.values()) {
            if (c.getCode() == code) {
                return c.name;
            }
        }
        return null;
    }
}
